package com.fish.gaiety.gateway.bootstrap;

import com.fish.gaiety.gateway.entity.UserApi;
import com.fish.gaiety.gateway.entity.dto.User;
import com.fish.gaiety.gateway.service.UserService;
import com.fish.gaiety.gateway.util.BaseAuthorities;
import com.fish.gaiety.gateway.util.BaseStatus;
import com.fish.gaiety.gateway.util.Gender;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author Jerry
 * @date 2022/9/28
 * @description 初始化的时候加载的一些东西
 */
@Component
@Order(-100)
@Slf4j
@RequiredArgsConstructor
public class Init implements CommandLineRunner {

    private final UserService userService;

    @Override
    public void run(String... args) {
        log.info("Start init Gateway ...");
        User user = new User();
        user.setName("Admin");
        user.setPassword("123456");
        user.setStatus(BaseStatus.ACTIVE);
        user.setPhone("1234567890");
        user.setSex(Gender.MALE);
        user.setNickName("Jerry");
        user.setEmail("123@123.com");
        user.setFirstName("Jerry");
        userService.create(user);
//        userServiceDeprecated.addUserAndGrantBaseAuthority(user, BaseAuthorities.ADMIN);
    }
}
